package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import java.util.Map;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.KDAdvise;

/**
 * 
 * @author 
 *
 */
@DAO
public interface KDAdviseDAO{
	
	@SQL("SELECT * FROM KDAdvise WHERE deleteFlag=1 #if(:t.msg!=''){ AND msg like '%##(:t.msg)%' } "
			+ "#if(:t.link!=''){ and link like '%##(:t.link)%' } "
			+ "#if(:t.phone!=''){ and phone like '%##(:t.phone)%' } "
			+ "ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<KDAdvise> query(@SQLParam("t") KDAdvise kDAdvise);
	
	@SQL("SELECT count(1) FROM KDAdvise WHERE deleteFlag=1 #if(:t.msg!=''){ AND msg like '%##(:t.msg)%' } "
			+ "#if(:t.link!=''){ and link like '%##(:t.link)%' } "
			+ "#if(:t.phone!=''){ and phone like '%##(:t.phone)%' } ")
    int querySize(@SQLParam("t") KDAdvise kDAdvise);
    
    @SQL("select * from KDAdvise where id=:1")
    KDAdvise queryById(int id);
    
    @SQL("UPDATE KDAdvise SET memo=:2 WHERE id=:1")
    void updateMemoById(int id,String memo);
    
    @SQL("UPDATE KDAdvise SET status=1 WHERE id=:1")
    void updateStatusById(int id);
    
    @SQL("UPDATE KDAdvise SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    //导出数据
    @SQL("select id,link,phone,msg,status,memo,deleteFlag,createAT,updateAT from KDAdvise where deleteFlag=1 #if(:start!=''){ and createAT>=:start } #if(:end!=''){ and createAT<=:end } order by id")
    List<Map> output(@SQLParam("start")String start, @SQLParam("end")String end);
}